<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<script>
	function ajaxDone_callback () {
		// 重新加载当前弹框页面数据
		if ($.pdialog._current != null) {
			$.pdialog.reload("app/flow/material.do?action=dialogFlowMaterialConfPage&rootId=${parent.id}");
		}
	}	
</script>

<table class="table" width="100%" layoutH="${parent ne null ? 75 : 135}">
	<thead>
		<tr>
			<th align="center" width="40px">序号</th>
			<th align="center">${parent ne null ? '材料名称' : '材料分类'}</th>
			<th align="center">材料描述</th>
			<c:if test="${parent ne null}">
			<th align="center">材料性质</th>
			</c:if>
			<th align="center">材料上移</th>
			<th align="center">材料下移</th>
			<c:if test="${parent eq null}">
			<th align="center">材料配置</th>
			</c:if>
			<th align="center">编辑</th>
			<th align="center">删除</th>
		</tr>
	</thead>
	<tbody>
		<logic:present name="datagrid">
			<logic:iterate name="datagrid" property="items" id="entity" indexId="idx">
				<tr id="drole-${role.id}" ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
					<td>${entity.sequence}</td>
					<td style="text-align:left">${entity.materialName}</td>
					<td style="text-align:left">${entity.materialDesc}</td>
					<c:if test="${parent ne null}">
					<td style="text-align:center; background-color:${entity.materialType eq 0 ? '#3FA156' : '#D9896A'}" >${entity.materialType eq 0 ? '建议提交' : '必须提交'}</td>
					</c:if>
					<td style="text-align:center">
						<c:choose>
							<c:when test="${entity.sequence gt 1}">
								<a href="app/flow/material.do?action=actionShiftFlowSequence&id=${entity.id}&offset=-1&src=SRC_PROCESS_MATERIAL" 
									target="ajaxToDo" title="确定要上移`${entity.materialName}`么?" class="oplink" callback="${parent ne null ? 'ajaxDone_callback()' : 'callback_tabRefresh()'}">上移</a>
							</c:when>
							<c:otherwise>
								<label class="opdisabled" title="已经是最上面一个节点了噢">上移</label>
							</c:otherwise>
						</c:choose>
					</td>
					<td style="text-align:center">
						<c:choose>
							<c:when test="${entity.sequence lt datagrid.totalCount}">
								<a href="app/flow/material.do?action=actionShiftFlowSequence&id=${entity.id}&offset=1&src=SRC_PROCESS_MATERIAL" 
									target="ajaxToDo" title="确定要下移`${entity.materialName}`么?" class="oplink" callback="${parent ne null ? 'ajaxDone_callback()' : 'callback_tabRefresh()'}">下移</a>
							</c:when>
							<c:otherwise>
								<label class="opdisabled" title="已经是最下面一个节点了噢">下移</label>
							</c:otherwise>
						</c:choose>
					</td>
					<c:if test="${parent eq null}">
					<td style="text-align:center">
						<a href="app/flow/material.do?action=dialogFlowMaterialConfPage&rootId=${entity.id}" 
							target="dialog" title="`${entity.materialName}`材料配置" class="oplink" width="820" height="458" rel="sysmgr_matconf_${entity.id}">材料配置</a>
					</td>
					</c:if>
					<td style="text-align:center">
						<a href="app/flow/material.do?action=dialogFlowMaterialPage&id=${entity.id}<c:if test='${parent ne null}'>&rootId=${parent.id}</c:if>" 
							target="dialog" title="`${entity.materialName}`材料编辑" class="oplink" width="504" height="280" rel="sysmgr_matedit_${entity.id}">编辑</a>
					</td>
					<td style="text-align:center">
						<a href="app/flow/material.do?action=actionRemoveFlowMaterial&id=${entity.id}" 
							target="ajaxTodo" title="确定删除该材料吗？" class="oplink" callback="${parent ne null ? 'ajaxDone_callback()' : 'callback_tabRefresh()'}">删除</a>
					</td>
				</tr>
			</logic:iterate>
		</logic:present>
	</tbody>
</table>

<!-- Pagination -->
<div class="panelBar">
	<div class="pages">
		<span>显示</span>
		<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
			<option value="20" ${pagingBean ne null && pagingBean.pageSize eq 20 ? 'selected="selected"' : ''}>20</option>
			<option value="50" ${pagingBean ne null && pagingBean.pageSize eq 50 ? 'selected="selected"' : ''}>50</option>
			<option value="100" ${pagingBean ne null && pagingBean.pageSize eq 100 ? 'selected="selected"' : ''}>100</option>
			<option value="200" ${pagingBean ne null && pagingBean.pageSize eq 200 ? 'selected="selected"' : ''}>200</option>
		</select>
		<span>条，共${pagingBean ne null ? pagingBean.totalItems : 0}条</span>
	</div>
	<div class="pagination" targetType="navTab" totalCount="${pagingBean ne null ? pagingBean.totalItems : 0}" numPerPage="${pagingBean ne null ? pagingBean.pageSize : 20}" pageNumShown="${pagingBean ne null ? pagingBean.pageNumShown : 10}" currentPage="${pagingBean ne null ? pagingBean.currentPage : 1}"></div>
</div>